<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    {{username}}
  </div>

  <script>


    var vm = new Vue({
      el: "#app",
      data: {
        username: 'hanye'
      },
      beforeCreate() {
        console.log("beforeCreate:", this.username)
      },
      created() {
        //最早可以发送ajax数据请求
        console.log('created:', this.username)
        // this.username = "hansai";
      },
      beforeMount() {
        console.log('before mount')
        console.log(document.getElementById("app"))
        this.username = "hansai";
      },
      mounted() {
        console.log('mounted:');
        console.log(document.getElementById("app"))
        console.log(this.$el)
        // this.username = "hansai";
        // setTimeout(() => {
        //   this.username = "hansai";
        // }, 1000)

        setTimeout(() => {
          vm.$destroy();
        }, 3000)
      },
      beforeUpdate() {
        console.log('beforeUPdate')
      },
      updated() {
        console.log('updated')
      },
      beforeDestroy() {
        console.log('beforeDestroy')
      },
      destroyed() {
        console.log('destroyed')
      }
    })

  </script>

</body>

</html>